package com.multithreading.thread;

import com.multithreading.thread.create.ThreadCreateRunnable;
import com.multithreading.thread.create.ThreadCreateThread;

import java.util.concurrent.*;

public class main {

    public static void main(String[] args) {
        ThreadCreateRunnable tcr = new ThreadCreateRunnable();
        new Thread(tcr).start();
        ThreadCreateThread tct = new ThreadCreateThread();
        tct.start();

        /********************/
        ExecutorService executor = new ThreadPoolExecutor(1, 5, 1, TimeUnit.MINUTES,
                new LinkedBlockingQueue<Runnable>());
        Callable<String> callable = new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "callable + futureTask";
            }
        };
        FutureTask ft = new FutureTask(callable);
        executor.execute(ft);
        Future future = executor.submit(callable);
        try {
            System.out.println("futureTask:" + ft.get());
            System.out.println("future:" + future.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        executor.shutdown();
    }
}
